﻿class Solution {
    public int lengthOfLongestSubstring(String s) {
        Set<Character> set=new HashSet<Character>();
int MaxLen=0;
for(int left=0,right=0;right<s.length();right++){
while(set.contains(s.charAt(right))){
set.remove(s.charAt(left));
left++;
}
    set.add(s.charAt(right));
MaxLen=Math.max(MaxLen,right-left+1);
}
return MaxLen;
    }
}